import React, { useState, useEffect } from 'react'

const Foo: React.FC = () => {
	const [loading, setLoading] = useState(true)
	useEffect(() => {
		const id = setTimeout(() => setLoading(false), 1000)
		return () => clearTimeout(id)
	}, []) // 没有依赖项, 只执行一次

	return (
		<>
			<div>
				{loading ? 'LoadingB...' : '异步请求完成...'}
				<button onClick={() => setLoading(!loading)}>loadingB</button>
			</div>
		</>
	)
}
export default Foo
